import 'package:flutter/material.dart';

class MyDomeTable extends StatefulWidget {
  @override
  _MyDomeTableState createState() => _MyDomeTableState();
}

class _MyDomeTableState extends State<MyDomeTable> {
  List demoList = [
    {
      "A": "list1",
      "B": "list2",
      "C": "list3",
    },
    {
      "A": "list1",
      "B": "list2",
      "C": "list3",
    },
    {
      "A": "list1",
      "B": "list2",
      "C": "list3",
    },
    {
      "A": "list1",
      "B": "list2",
      "C": "list3",
    },
  ];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('测试动态表格'),
      ),
      body: Container(
        child: ListView(
          children: <Widget>[
            Table(
              border: TableBorder.all(width: 1.0,color: Colors.blueAccent),
              children: _tableRowList(),
            ),
          ],
        )
      ),
    );


  }
  _tableRowList() {
     var count = demoList.length;
     dynamic content;
     List<TableRow> Tlist = <TableRow> [
       TableRow(
           children: [
             Center(child: Text('标题1')),
             Center(child: Text('标题2')),
             Center(child: Text('标题3')),
           ],
       ),
     ];
     for (var i = 0; i<count; i++) {
       content = TableRow(
           children: [
             Center(child: Text(demoList[i]['A'].toString())),
             Center(child: Text(demoList[i]['B'].toString())),
             Center(child: Text(demoList[i]['C'].toString())),
           ]
       );
       Tlist.addAll(content);
     }

     return Tlist;
   }

}
